<%@page import="com.fzb.forum4j.po.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="include/menu.jsp"/>
<link rel="stylesheet" href="assets/css/ace.min.css" />
<link rel="stylesheet" href="edit/themes/default/default.css" />
<link rel="stylesheet" href="edit/plugins/code/prettify.css" />
<script charset="utf-8" src="edit/kindeditor-min.js"></script>
<script charset="utf-8" src="edit/lang/zh_CN.js"></script>
<script>
	KindEditor.ready(function(K) {
		var editor1 = K.create('textarea[name="t.content"]', {
			uploadJson : '${url}/article/uploadFile',
			allowFileManager : true,
			
			afterBlur: function(){this.sync();
			{
				
			}}
			
		});
		prettyPrint();
	});
</script>

<script type="text/javascript">

	function checkSubmit() {
		if(document.getElementById("title").value=="" || document.getElementById("content").value=="")
		{
			document.getElementById("msg").innerHTML="文章的标题和内容都不能为空。。。。。";
			return;
		}
		document.getElementById("type").value = "add";
		document.getElementById("addorPre").submit();
	}
	function preview() {
		document.getElementById("type").value = "preview";
		document.getElementById("addorPre").submit();
	}
	function update() {
		document.getElementById("type").value = "update";
		document.getElementById("addorPre").submit();
	}
</script>
<script type="text/javascript">
	
	$(function(){
		var $tags=$("#inp");
		$(".tag").click(function(e){
			$tags.val($tags.val()+$(this).text()+",");
			$(this).remove();
			e.preventDefault();
		});
		$("#translate").click(function(){
			$.post('<%=request.getAttribute("url")%>/post/api/translate',{"content":$("#title").val()},function(data){
				if($("#result").length==0){
					$("#translate").after("<input name='alias' id='result' value='"+data+"'>");
				}
				else{
					$("#result").attr("value",data);
				}
			});
		});
	});
</script>
	<div class="contents" >
			<div class="grid_wrapper" >
			 
	${requestScope.msg}
	<h3 id="msg" ></h3>
	<form action="${url}/a/news/add" class="form-horizontal" role="form" id="addorPre" method="post">
		<input type="hidden" id="type">
		    <input name="t.title" id="title" size="60" maxlength="60"  class="col-xs-10 col-sm-5" type="text" placeholder="请输入文章标题"></input><a id="translate">翻译</a>
			<div class="g_12 separator"><span></span></div>
			 <textarea
						name="t.content" cols="100" rows="8"  id="content"
						style="width:760px; height:500px; visibility:hidden; z-index: 9999;"></textarea>

	<div class="g_12 separator"><span></span></div>
	<div class="col-xs-3">
		<label>
			<input class="ace ace-switch ace-switch-5" type="checkbox" name="t.cancomment">
			<span class="lbl">&nbsp;能发布评论吗</span>
		</label>
	 
		<label>
			<input class="ace ace-switch ace-switch-5" type="checkbox" name="t.recommended">
			<span class="lbl">&nbsp;推荐吗</span>
		</label>
		<label for="form-field-select-1">类型</label>
		
		<select name="t.type.typeId" id="form-field-select-3" class="form-control">
			<option value="1">编程</option>
		  <c:forEach items="${sessionScope.init.type}" var="type">
		<option value="${type.typeId }">${type.typeName}</option>
		</c:forEach>
		</select>
	</div>

	<div class="g_12 separator"><span></span></div>
		<input value="" name="t.keywords" size="50" id="inp"  placeholder=""/>
			<c:forEach items="${sessionScope.init.tag}" var="tags">
				<a class="tag">${tags.text}</a>&nbsp;
			</c:forEach>
					<div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button class="btn btn-info" type="button" onClick="checkSubmit()">
								<i class="icon-ok bigger-110"></i>
								提        交
							</button>

							&nbsp; &nbsp; &nbsp;
							<button class="btn" type="reset" onClick="preview()">
								<i class="icon-undo bigger-110"></i>
								预览
							</button>
						</div>
					</div>
	</form>
<jsp:include page="include/footer.jsp"/>